package cn.sciento.starter.social.qq.config;

import cn.sciento.starter.social.core.common.configurer.SocialConnectionFactoryBuilder;
import cn.sciento.starter.social.core.common.connect.SocialApiAdapter;
import cn.sciento.starter.social.core.common.connect.SocialConnectionFactory;
import cn.sciento.starter.social.core.common.connect.SocialServiceProvider;
import cn.sciento.starter.social.core.common.connect.SocialTemplate;
import cn.sciento.starter.social.core.common.constant.ProviderEnum;
import cn.sciento.starter.social.core.provider.Provider;
import cn.sciento.starter.social.qq.connect.QQApiAdapter;
import cn.sciento.starter.social.qq.connect.QQConnectionFactory;
import cn.sciento.starter.social.qq.connect.QQServiceProvider;
import cn.sciento.starter.social.qq.connect.QQTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QQSocialBuilder implements SocialConnectionFactoryBuilder {
  public String getProviderId() {
    return ProviderEnum.qq.name();
  }
  
  public SocialConnectionFactory buildConnectionFactory(Provider provider) {
    String URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";
    String URL_GET_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";
    String URL_GET_OPEN_ID = "https://graph.qq.com/oauth2.0/me";
    String URL_GET_USER_INFO = "https://graph.qq.com/user/get_user_info";
    provider.setAuthorizeUrl("https://graph.qq.com/oauth2.0/authorize");
    provider.setAccessTokenUrl("https://graph.qq.com/oauth2.0/token");
    provider.setOpenIdUrl("https://graph.qq.com/oauth2.0/me");
    provider.setUserInfoUrl("https://graph.qq.com/user/get_user_info");
    QQApiAdapter apiAdapter = new QQApiAdapter();
    QQTemplate template = new QQTemplate(provider);
    QQServiceProvider serviceProvider = new QQServiceProvider(provider, (SocialTemplate)template);
    return (SocialConnectionFactory)new QQConnectionFactory(provider, (SocialServiceProvider)serviceProvider, (SocialApiAdapter)apiAdapter);
  }
}
